OptionStepper
| Kind of class: | class |
|---|---|
| Inherits from: | UIComponent < MovieClip |
| Classpath: | gfx.controls.OptionStepper |
| File last modified: | Tuesday, 29 June 2010, 09:03:27 |
The OptionStepper component, similar to the NumericStepper, displays a single value, but is capable of displaying more than just numbers. It uses a DataProvider instance to query for the current value, therefore is able to support an arbitrary number of elements of different types. The dataProvider is assigned via code, as shown in the example below:
optionStepper.dataProvider = [“item1”, “item2”, “item3”, “item4”, “item5”];
Inspectable Properties
A MovieClip that derives from the OptionStepper component will have the following inspectable properties:
The OptionStepper component supports three states based on its focused and disabled properties.
All event callbacks receive a single Object parameter that contains relevant information about the event. The following properties are common to all events.
optionStepper.dataProvider = [“item1”, “item2”, “item3”, “item4”, “item5”];
Inspectable Properties
A MovieClip that derives from the OptionStepper component will have the following inspectable properties:
- visible: Hides the component if set to false.
- disabled: Disables the component if set to true.
- enableInitCallback: If set to true, _global.CLIK_loadCallback() will be fired when a component is loaded and _global.CLIK_unloadCallback will be called when the component is unloaded. These methods receive the instance name, target path, and a reference the component as parameters. _global.CLIK_loadCallback and _global.CLIK_unloadCallback should be overriden from the game engine using GFx FunctionObjects.
- soundMap: Mapping between events and sound process. When an event is fired, the associated sound process will be fired via _global.gfxProcessSound, which should be overriden from the game engine using GFx FunctionObjects.
The OptionStepper component supports three states based on its focused and disabled properties.
- default or enabled state.
- focused state, that highlights the textField area.
- disabled state.
All event callbacks receive a single Object parameter that contains relevant information about the event. The following properties are common to all events.
- type: The event type.
- target: The target that generated the event.
- show: The component's visible property has been set to true at runtime.
- hide: The component's visible property has been set to false at runtime.
- change: The OptionStepper’s value has changed.
- stateChange: The OptionStepper’s focused or disabled property has changed.
- state: Name of the new state. String type. Values "default", "focused" or "disabled".
Summary
Constructor
Instance properties
- selectedItem
- A reference to the currently selected item in the dataProvider.
- soundMap
- Mapping between events and sound process
- textField
- A reference to the textField instance used to display the selected item's label.
- nextBtn
- A reference to the next button instance used to increment the selectedIndex.
- prevBtn
- A reference to the previous button instance used to decrement the selectedIndex.
- disabled
- Disable this component.
- dataProvider
- The data model displayed in the component.
- selectedIndex
- The index of the item in the dataProvider that is selected in a single-selection list.
- labelField
- The name of the field in the dataProvider model to be displayed as the label in the TextInput field.
- labelFunction
- The function used to determine the label for an item.
Instance properties inherited from UIComponent
__height __width _disabled _displayFocus _focused addEventListener cleanUpEvents disabled dispatchEvent displayFocus enableInitCallback focused focusHandlerReference focusTarget hasEventListener height initialized invalidationIntervalID removeAllEventListeners removeEventListener sizeIsInvalid soundMap visible width
Class methods
Class methods inherited from UIComponent
Instance methods
- itemToLabel
- Convert an item to a label string using the labelField and labelFunction.
- invalidateData
- The current data has become invalid, either by a data change, or a display change.
- handleInput
- Handle input from the game, via controllers or keyboard.Instance methods inherited from UIComponent
Constructor
OptionStepper
function OptionStepper (
)
The constructor is called when a OptionStepper or a sub-class of OptionStepper is instantiated on stage or by using
attachMovie() in ActionScript. This component can not be instantiated using new syntax. When creating new components that extend OptionStepper, ensure that a super() call is made first in the constructor. Instance properties
dataProvider
dataProvider:Object
(read,write)
The data model displayed in the component. The dataProvider can be an Array or any object exposing the appropriate API, defined in the
IDataProvider interface. If an Array is set as the dataProvider, functionality will be mixed into it by the DataProvider.initialize method. When a new DataProvider is set, the selectedIndex property will be reset to 0. disabled
disabled:Boolean
(read,write)
Disable this component. Focus (along with keyboard events) and mouse events will be suppressed if disabled.
Component metadata:
| Inspectable | defaultValue: "false" verbose: "1" |
|---|
labelField
labelField:String
(read,write)
The name of the field in the
dataProvider model to be displayed as the label in the TextInput field. A labelFunction will be used over a labelField if it is defined. See also:
labelFunction
labelFunction:Function
(read,write)
The function used to determine the label for an item. A
labelFunction will override a labelField if it is defined. See also:
nextBtn
A reference to the next button instance used to increment the
selectedIndex. prevBtn
A reference to the previous button instance used to decrement the
selectedIndex. selectedIndex
selectedIndex:Number
(read,write)
The index of the item in the
dataProvider that is selected in a single-selection list. selectedItem
selectedItem:Object
(read,write)
A reference to the currently selected item in the dataProvider.
soundMap
soundMap:Object = { theme:"default", focusIn:"focusIn", focusOut:"focusOut", change:"change" }
(read,write)
Mapping between events and sound process
Component metadata:
| Inspectable | defaultValue: "theme type: "Object" |
|---|
textField
textField:TextField
(read,write)
A reference to the textField instance used to display the selected item's label. Note that when state changes are made, the textField instance may change, so changes made to it externally may be lost.
Instance methods
handleInput
Handle input from the game, via controllers or keyboard. The default handleInput will handle standalone and composite components.
Parameters:
details :
An
InputDetails object containing details from the interaction.pathToFocus:
A list of children in the focus path that are below this component. Components are responsible for calling
handleInput() on the next component in the pathToFocus unless they choose to intercept the call.Overrides:
invalidateData
function invalidateData (
) : Void
The current data has become invalid, either by a data change, or a display change.
itemToLabel
function itemToLabel (
item:Object) : String
Convert an item to a label string using the
labelField and labelFunction. Parameters:
item:
The item to convert to a label.
Returns:
- The converted label string.
See also: